package com.loveshare.blog.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.loveshare.common.util.DateUtil;
import com.loveshare.common.util.HttpClientIpUtil;
import com.loveshare.common.util.HttpRequest;
import com.loveshare.log.service.LogService;

/**
 * 
 * ClassName: BlogController 
 * @Description: 博客控制器
 * @author 爱分享
 * @date 2017年12月20日
 */
@Controller
@RequestMapping(value="blog")
public class BlogController {

	@Autowired
	private LogService logService;
	/**
	 * 博客首页
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String blogIndex(HttpServletRequest request,ModelMap map){
		String ip=HttpClientIpUtil.getIP(request);
		//记录访问者信息
		logService.addArticleInfo(ip,HttpRequest.getIpRegion(ip),1);
		//提醒用户时间
		request.getSession().setAttribute("dataMsg", DateUtil.dataMsg());
		return "pc/myblog/index";
	}
}
